package cn.tedu.charging.cost.controller;


import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.common.pojo.param.ChargingProcessParam;
import cn.tedu.charging.common.pojo.vo.ChargingProcessVO;
import cn.tedu.charging.cost.service.CostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "计算费用服务")
@RestController
@Slf4j
@RequestMapping("/cost")
public class CostController {
    @Autowired
    private CostService costService;

    @ApiOperation(value = "计算费用")
    @PostMapping("/calculate")
    public JsonResult calculateCost(@RequestBody ChargingProcessParam param){
        log.debug("计算价格入参：{}",param);
        ChargingProcessVO chargingProcessVO
                = costService.calculateCost(param);
        log.debug("计算价格,入参：{},出参：{}",param,chargingProcessVO);
        return JsonResult.ok(chargingProcessVO,"计算成功");
    }

}
